package com.next.aap.server.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.next.aap.client.CandidateDto;
import com.next.aap.client.ManifestoDto;
import com.next.core.exception.AppException;

@Controller
public class ElectionCampaignController extends BaseController{

	
	@RequestMapping(value="/candidate/{language}/save", method = RequestMethod.POST)
    @ResponseBody
    public CandidateDto saveCandidate(@PathVariable String language,@RequestBody CandidateDto candidateDto) throws AppException{
		return appService.saveCandidate(candidateDto);
	}
	
	@RequestMapping(value="/candidate/get/{language}/{assemblyConstituencyId}", method = RequestMethod.GET)
    @ResponseBody
    public String getCandidateOfAssemblyConstituency(@PathVariable String language,@PathVariable Long assemblyConstituencyId) throws AppException{
		return candidateCache.getAllCandidatesOfAssemblyConstituency(assemblyConstituencyId);
	}
	
	@RequestMapping(value="/manifesto/{language}/save", method = RequestMethod.POST)
    @ResponseBody
    public ManifestoDto saveManifesto(@PathVariable String language,@RequestBody ManifestoDto manifestoDto) throws AppException{
		return appService.saveManifesto(manifestoDto);
	}
	
	@RequestMapping(value="/manifesto/get/{language}/{assemblyConstituencyId}", method = RequestMethod.GET)
    @ResponseBody
    public String getManifestoOfAssemblyConstituency(@PathVariable String language,@PathVariable Long assemblyConstituencyId) throws AppException{
		return manifestoCache.getManifestoOfAssemblyConstituency(assemblyConstituencyId);
	}
}
